package org.dinnermate.gui.trackers;

import org.dinnermate.menu.MenuItem;
import java.sql.SQLException;

import net.java.ao.EntityManager;

public class MenuIncomeTracker
{
	String[][] incomeTable;
	MenuItem[] menuItems;
	
	public MenuIncomeTracker(EntityManager em){
		try{
			menuItems = em.find(MenuItem.class);
			incomeTable = new String[menuItems.length][4];
			populateArray();
		} catch (SQLException e){
			
		}
	}
	
	private void populateArray(){
		for(int i = 0, index = 0; i < menuItems.length; i++, index++){
			incomeTable[i][0] = menuItems[index].getName();
			incomeTable[i][1] = menuItems[index].getNumOfOrders() + "";
			incomeTable[i][2] = menuItems[index].getPrice() + "";
			incomeTable[i][3] = (menuItems[index].getNumOfOrders() * menuItems[index].getPrice()) + "";
		}
	}
	
	public String[][] getMenuIncomeArray(){
		return incomeTable;
	}
}
